<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="style.css" />
    <link rel="stylesheet" type="text/css" href="form.css" />
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>

    <script>
        $(function () {
            var match,
	        pl = /\+/g, // Regex for replacing addition symbol with a space
	        search = /([^&=]+)=?([^&]*)/g,
	        decode = function (s) {
	            return decodeURIComponent(s.replace(pl, " "));
	        },
	        query = window.location.search.substring(1);

            var urlParams = {};
            while (match = search.exec(query))
                urlParams[decode(match[1])] = decode(match[2]);
            window.assignmentId = urlParams["assignmentId"];
            window.turkSubmitTo = urlParams["turkSubmitTo"];
            window.gamesOrder = urlParams["gamesOrder"];

            $("#target").submit(function (e) {
                e.preventDefault();
                var headerData = {
                    gameType: window.gamesOrder,
                    assignmentId: window.assignmentId,
                    enjoyGame: $('input:radio[name=enjoyGame]:checked').val(),
                    performanceSelfAssessment: $('input:radio[name=performanceSelfAssessment]:checked').val(),
                    alertFrequency: $('input:radio[name=alertFrequency]:checked').val(),
                    setFrequency: $('input:radio[name=setFrequency]:checked').val(),
                    secondsInAdvanceForAlert: $('input:radio[name=secondsInAdvanceForAlert]:checked').val(),
                    setAlertTiming: $('input:radio[name=setAlertTiming]:checked').val(),
                    maintenanceAlertsHelpful: $('input:radio[name=maintenanceAlertsHelpful]:checked').val(),
                    gameStrategyDesc: $("#gameStrategyDesc").val(),
                    takeRisks: $('input:radio[name=takeRisks]:checked').val(),
                    bugsOccured: $('input:radio[name=bugsOccured]:checked').val(),
                    bugDescriptionIfExist: $("#bugDescriptionIfExist").val(),
                    freeText: $("#freeText").val(),
                };

                $.ajax({
                    type: "POST",

                    url: "../MGGameService.svc/lastData/",

                    data: JSON.stringify(headerData),
                    success: function () {
                        window.location = "thank.html?turkSubmitTo=" + window.turkSubmitTo + "&assignmentId=" + window.assignmentId;
                    },
                    error: function (jqXHR, textStatus, errorThrown) {
                        console.log(errorThrown);
                    },
                    dataType: 'json'
                });
            }
   )
        }) </script>
</head>
<body>
    <div id="form" class="lastForm">
        <p>We want to test your attitude to maintenance and alerts management.</p>
        <p>You must answer ALL questions and submit the HIT before we will pay you.</p>

        <form id="target">
            <div style="overflow: auto">
                <p>
                    <label>
                        Did you enjoy the game?
                    </label>
                    <br />
                    Did not enjoy
                    <input type="radio" name="enjoyGame" value="1">
                    <input type="radio" name="enjoyGame" value="2">
                    <input type="radio" name="enjoyGame" value="3">
                    <input type="radio" name="enjoyGame" value="4">
                    <input type="radio" name="enjoyGame" value="5">
                    <input type="radio" name="enjoyGame" value="6">
                    <input type="radio" name="enjoyGame" value="7">
                    <input type="radio" name="enjoyGame" value="8">
                    <input type="radio" name="enjoyGame" value="9">
                    <input type="radio" name="enjoyGame" value="10">

                    Enjoyed very much
                </p>
                <p>
                    <label>
                        How well do you think that you performed in the game?
                    </label>
                    <br />
                    Not well
                    <input type="radio" name="performanceSelfAssessment" value="1">
                    <input type="radio" name="performanceSelfAssessment" value="2">
                    <input type="radio" name="performanceSelfAssessment" value="3">
                    <input type="radio" name="performanceSelfAssessment" value="4">
                    <input type="radio" name="performanceSelfAssessment" value="5">
                    <input type="radio" name="performanceSelfAssessment" value="6">
                    <input type="radio" name="performanceSelfAssessment" value="7">
                    <input type="radio" name="performanceSelfAssessment" value="8">
                    <input type="radio" name="performanceSelfAssessment" value="9">
                    <input type="radio" name="performanceSelfAssessment" value="10">

                    Very well
                </p>
                <p>
                    <label>
                        In two of the games which you played you received maintenance alerts. In that game the alerts were given every 20 seconds.  Would you prefer a different frequency?
                    </label>
                    <br />
                    <input type="radio" name="alertFrequency" value="yesPreferMoreFrequency">Yes, I would prefer <b>more</b> frequent alerts.<br />
                    <input type="radio" name="alertFrequency" value="noTrustSystem">No (I trust the system).<br />
                    <input type="radio" name="alertFrequency" value="yesPreferLessFrequency">Yes, I would prefer <b>less</b> frequent alerts<br />
                </p>
                <p>
                    <label>
                        If you had to play the game several times again, would you prefer to set the frequency of the alerts on your own?
                    </label>
                    <br />
                    <input type="radio" name="setFrequency" value="No">No (I trust the system). <br />
                    <input type="radio" name="setFrequency" value="Probably not">Probably not.<br />
                    <input type="radio" name="setFrequency" value="Yes, at the beginning of the experiment">Yes, at the beginning of the experiment.<br />
                    <input type="radio" name="setFrequency" value="Yes, at the beginning of each game.">Yes, at the beginning of each game.<br />
                </p>
                <p>
                    <label>
                        In two of the games which you played you received maintenance alerts. In that game the alerts were presented starting 3 seconds before there was need to take a maintenance action.   How many seconds in advance would you prefer to receive these alerts?
                    </label>
                    <br />
                    <input type="radio" name="secondsInAdvanceForAlert" value="0">0<br />
                    <input type="radio" name="secondsInAdvanceForAlert" value="1">1<br />
                    <input type="radio" name="secondsInAdvanceForAlert" value="2">2<br />
                    <input type="radio" name="secondsInAdvanceForAlert" value="3">3<br />
                    <input type="radio" name="secondsInAdvanceForAlert" value="4">4<br />
                    <input type="radio" name="secondsInAdvanceForAlert" value="5">5<br />
                </p>
                <p>
                    <label>
                        If you had to play the game several times again, would you prefer to set the timing of the maintenance alerts (how much time in advance they appear) manually?
                    </label>
                    <br />
                    <input type="radio" name="setAlertTiming" value="No">No (I trust the system). <br />
                    <input type="radio" name="setAlertTiming" value="Probably not">Probably not.<br />
                    <input type="radio" name="setAlertTiming" value="Yes, at the beginning of the experiment">Yes, at the beginning of the experiment.<br />
                    <input type="radio" name="setAlertTiming" value="Yes, at the beginning of each game.">Yes, at the beginning of each game.<br />
                </p>
                <p>
                    <label>
                        Did you find the alerts for maintenance helpful?
                    </label>
                    <br />
                    Not helpful
                    <input type="radio" name="maintenanceAlertsHelpful" value="1">
                    <input type="radio" name="maintenanceAlertsHelpful" value="2">
                    <input type="radio" name="maintenanceAlertsHelpful" value="3">
                    <input type="radio" name="maintenanceAlertsHelpful" value="4">
                    <input type="radio" name="maintenanceAlertsHelpful" value="5">
                    <input type="radio" name="maintenanceAlertsHelpful" value="6">
                    <input type="radio" name="maintenanceAlertsHelpful" value="7">
                    <input type="radio" name="maintenanceAlertsHelpful" value="8">
                    <input type="radio" name="maintenanceAlertsHelpful" value="9">
                    <input type="radio" name="maintenanceAlertsHelpful" value="10">

                    Very helpful
                </p>
                <p>
                    <label>
                        Please describe your game strategy:<br />
                    </label>

                    <textarea rows="3" cols="50" id="gameStrategyDesc" required></textarea>
                </p>
                <p>
                    <label>
                        How do you see yourself: are you generally a person who is fully prepared to take risks or do you try to avoid taking risks?
                    </label>
                    <br />
                    Not at all willing to take risks
                    <input type="radio" name="takeRisks" value="1">
                    <input type="radio" name="takeRisks" value="2">
                    <input type="radio" name="takeRisks" value="3">
                    <input type="radio" name="takeRisks" value="4">
                    <input type="radio" name="takeRisks" value="5">
                    <input type="radio" name="takeRisks" value="6">
                    <input type="radio" name="takeRisks" value="7">
                    <input type="radio" name="takeRisks" value="8">
                    <input type="radio" name="takeRisks" value="9">
                    <input type="radio" name="takeRisks" value="10">

                    Very willing to take risks.
                </p>
                <p>
                    <label>
                        Did you encounter any bugs during the game?
                    </label>
                    <br />
                    <input type="radio" name="bugsOccured" value="No">No
                    <input type="radio" name="bugsOccured" value="Yes">Yes
                </p>
                <p>
                    <label>
                        If yes, please tell us about the bugs so we can fix them:<br />
                    </label>

                    <textarea rows="3" cols="50" id="bugDescriptionIfExist"></textarea>
                </p>
                <p>
                    <label>
                        Please share any additional comments you may have:<br />
                    </label>
                    <textarea rows="3" cols="50" id="freeText"></textarea>
                </p>
            </div>
            <div id="errorMessageHeader"></div>
            <p>
                <input type="submit" value="Send" />
            </p>
        </form>
    </div>
</body>
</html>
